# class Solution:
#     def isValidSudoku(self, board: List[List[str]]) -> bool:
#         for i in range(9):
#             rmapper=[0]*10
#             cmapper=[0]*10
#             for j in range(9):
#                 if board[i][j]!=".":
#                     if rmapper[ord(board[i][j])-ord('0')]==1:
#                         return False
#                     else:
#                        rmapper[ord(board[i][j])-ord('0')]=1
#                 if board[j][i]!='.':
#                     if cmapper[ord(board[j][i])-ord('0')]==1:
#                         return False
#                     else:
#                        cmapper[ord(board[j][i])-ord('0')]=1 
#         for i in range(3):
#             for j in range(3):
#                 mapper=[0]*10
#                 for x in range(3):
#                     for y in range(3):
#                         if board[3*i+x][3*j+y]!=".":
#                             if mapper[ord(board[3*i+x][3*j+y])-ord('0')]==1:
#                                 return False
#                             else:
#                                 mapper[ord(board[3*i+x][3*j+y])-ord('0')]=1 
#         return True 

'''
执行用时：
60 ms
, 在所有 Python3 提交中击败了
28.13%
的用户
内存消耗：
14.9 MB
, 在所有 Python3 提交中击败了
11.86%
的用户
'''


# class Solution:
#     def isValidSudoku(self, board: List[List[str]]) -> bool:
#         for i in range(3):
#             for j in range(3):
#                 rmapper=[0]*10
#                 cmapper=[0]*10
#                 mapper=[0]*10
#                 for x in range(3):
#                     for y in range(3):
#                         if board[3*i+x][3*j+y]!=".":
#                             if mapper[ord(board[3*i+x][3*j+y])-ord('0')]==1:
#                                 return False
#                             else:
#                                 mapper[ord(board[3*i+x][3*j+y])-ord('0')]=1 
#                         if board[i*3+j][x*3+y]!=".":
#                             if rmapper[ord(board[i*3+j][x*3+y])-ord('0')]==1:
#                                 return False
#                             else:
#                                 rmapper[ord(board[i*3+j][x*3+y])-ord('0')]=1
#                         if board[x*3+y][i*3+j]!='.':
#                             if cmapper[ord(board[x*3+y][i*3+j])-ord('0')]==1:
#                                 return False
#                             else:
#                                 cmapper[ord(board[x*3+y][i*3+j])-ord('0')]=1                     
#         return True 

'''
执行用时：
48 ms
, 在所有 Python3 提交中击败了
79.72%
的用户
内存消耗：
14.8 MB
, 在所有 Python3 提交中击败了
15.94%
的用户
'''
class Solution:
    def isValidSudoku(self, board: List[List[str]]) -> bool:
        for i in range(3):
            for j in range(3):
                rmapper=1023
                cmapper=1023
                mapper=1023
                for x in range(3):
                    for y in range(3):
                        if board[3*i+x][3*j+y]!=".":
                            temp=1<<(ord(board[3*i+x][3*j+y])-ord('0'))
                            if mapper|temp!=mapper:
                                return False
                            else:
                                mapper-=temp
                        if board[i*3+j][x*3+y]!=".":
                            temp=1<<(ord(board[i*3+j][x*3+y])-ord('0'))
                            if rmapper|temp!=rmapper:
                                return False
                            else:
                                rmapper-=temp
                        if board[x*3+y][i*3+j]!='.':
                            temp=1<<(ord(board[x*3+y][i*3+j])-ord('0'))
                            if cmapper|temp!=cmapper:
                                return False
                            else:
                                cmapper-=temp  
        return True 